package org.dey.controller;


import org.dey.entity.Result;
import org.dey.pojo.CheckGroup;
import org.dey.pojo.CheckUpload;
import org.dey.pojo.Order;
import org.dey.pojo.PageVo;
import org.dey.service.CheckUploadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * @author deyran
 * @classname
 * @see CheckUploadController
 */
@RestController
public class CheckUploadController {

    @Autowired(required = false)
    CheckUploadService checkuploadService;

    //    打开用户管理页面显示数据
    @PostMapping("checkupload.action/{pageNum}/{pagesize}")
    public PageVo<CheckUpload> checkuploadlist(@PathVariable int pageNum, @PathVariable int pagesize,@RequestBody CheckUpload checkupload){

        PageVo<CheckUpload> querycheckupload = checkuploadService.querycheckupload(checkupload, pageNum, pagesize);
        System.out.println("Controller——querymember——"+querycheckupload);
        return querycheckupload;
    }

    //添加
    @PostMapping("checkupload.action")
    public Result addcheckupload(@RequestBody CheckUpload checkupload){

        Result insertcheckupload = checkuploadService.insertcheckupload(checkupload);

        return insertcheckupload;
    }

    //删除
    @DeleteMapping("checkupload.action/{id}")
    public Result delcheckuploadbyid(@PathVariable int id){

        Result delcheckupload = checkuploadService.delcheckupload(id);

        return delcheckupload;
    }

    //修改先根据id查到该数据
    @GetMapping("checkupload.action/{id}")
    public CheckUpload querycheckuploadbyid(@PathVariable Integer id){

        CheckUpload querycheckuploadbyid = checkuploadService.querycheckuploadbyid(id);

        return querycheckuploadbyid;
    }

    //根据id修改
    @PutMapping("checkupload.action")
    public Result updatecheckuploadbyid(@RequestBody CheckUpload checkupload){

        Result updatecheckuploadbyid = checkuploadService.updatecheckuploadbyid(checkupload);

        return updatecheckuploadbyid;
    }

    //根据id提交
    @PutMapping("submitecheckupload.action/{id}")
    public Result submitecheckupload(@PathVariable Integer id){

        Result updatecheckuploadbyid = checkuploadService.submitcheckupload(id);

        return updatecheckuploadbyid;
    }

    @GetMapping("getordername.action")
    public List<Order> queryorderName(){
        List<Order> orders = checkuploadService.queryorderName();
        return orders;
    }

    @GetMapping("getchecks.action")
    public List<CheckGroup> querychecks(){
        List<CheckGroup> checks = checkuploadService.queryallcheck();
        return checks;
    }
    
}
